package com.example.petstore.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.petstore.domain.Message;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface MessageMapper extends BaseMapper<Message> {
    @Select("SELECT userid " +
            "FROM message " +
            "WHERE (userid, date) IN ( " +
            "    SELECT userid, MAX(date) " +
            "    FROM message " +
            "    GROUP BY userid" +
            ") " +
            "ORDER BY date DESC")
    List<String> selectDistinctUserIDsAndUsernamesOrderByDateDesc();


}
